﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Public_Samedish : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PreRender += new EventHandler(InitPage);
        }
    }

    protected void InitPage(object sender, EventArgs e)
    {
        InitData();
    }
    protected void InitData()
    {
        String queryString = Request.QueryString["id"];
        int dishId = 0;
        if (!int.TryParse(queryString, out dishId))
            return;

        int districtId = 0;
        Int16 servedDistrictId = 0;
        if (Session["RestaurantDistrictSelected"] != null)
        {
            districtId = Convert.ToInt32(Session["RestaurantDistrictSelected"].ToString());
        }

        if (Session["ServedDistrictSelected"] != null)
        {
            servedDistrictId = Convert.ToInt16(Session["ServedDistrictSelected"].ToString());
        }

        System.Data.SqlClient.SqlDataReader reader = BLL.Command.GetCategoryDishesByDishId(dishId, districtId, servedDistrictId);
        samedish_datagrid.DataSource = reader;
        samedish_datagrid.DataBind();
    }

    protected void FilterSelectedIndexChanged(object sender, int districtId, Int16 servedDistrictId)
    {
        String queryString = Request.QueryString["id"];
        int dishId = 0;
        if (!int.TryParse(queryString, out dishId))
            return;

        samedish_datagrid.DataSource = BLL.Command.GetCategoryDishesByDishId(dishId, districtId, servedDistrictId);
        samedish_datagrid.DataBind();
    }
}

